n,k = map(int, input().split())
arr = list(map(int, input().split()))
m = min(arr)
k -= 1
ov = m*n
for i in range(n):
arr[i] -= m
while arr[k] > 0:
ov += 1
arr[k] -= 1
k = (k-1)%n
arr[k] = ov
print(*arr)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define cin_2d(vec, n, m) for(int i = 0; i < n; i++) for(int j = 0; j < m && cin >> vec[i][j]; j++);
#define fixed(n) fixed << setprecision(n)
#define cout_2d(vec, n, m) for(int i = 0; i < n; i++, cout << "\n") for(int j = 0; j < m && cout << vec[i][j] ; j++);
#define loop(n) for(int i=0; i<n; ++i)
#define loopj(n) for(int j=0; j<n; ++j)
#define trav(a, b) for(auto &a:b)
#define YES cout << "YES"<<endl;
#define NO cout << "NO" << endl;
#define yn cout<<(flag1?"YES":"NO")<<endl;
#define mem(a, b) memset(a , b , sizeof a);
#define FO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sz(s) (int)s.size()
#define all(vec) vec.begin(), vec.end()
#define debug(x) cout << #x << ": " << (x) << "\n";
#define debugLine(x) cout << #x << ": " << (x) << " ";
const ll OO = 0x3f3f3f3f, mod = 1e9 + 7, N = 1e3 + 5;
ll n, m, k, l, r;
bool flag1;
void _go() {
cin >> n >> k;
k--;
vector<ll> v(n);
loop(n)cin >> v[i];
int val = *min_element(all(v));
ll sum = 0;
loop(n) {
v[i] -= val;
sum += val;
}
while (v[k])
{
v[k]--;
k=(k-1+n)%n;
sum++;
}
v[(k+n)%n]+=sum;
loop(n)cout<<v[i]<<" ";
cout<<endl;
}
int main() {
//FO
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int t = 1;
//cin >> t;
while (t--) {
_go();
}
return 0;
}
450A - Jzzhu and Children | 546A - Soldier and Bananas |
32B - Borze | 1651B - Prove Him Wrong |
381A - Sereja and Dima | 41A - Translation |
1559A - Mocha and Math | 832A - Sasha and Sticks |
292B - Network Topology | 1339A - Filling Diamonds |
910A - The Way to Home | 617A - Elephant |
48A - Rock-paper-scissors | 294A - Shaass and Oskols |
1213A - Chips Moving | 490A - Team Olympiad |
233A - Perfect Permutation | 1360A - Minimal Square |
467A - George and Accommodation | 893C - Rumor |
227B - Effective Approach | 1534B - Histogram Ugliness |
1611B - Team Composition Programmers and Mathematicians | 110A - Nearly Lucky Number |
1220B - Multiplication Table | 1644A - Doors and Keys |
1644B - Anti-Fibonacci Permutation | 1610A - Anti Light's Cell Guessing |
349B - Color the Fence | 144A - Arrival of the General |